﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using VirtualAccess;
using VirtualAccess.Devices.Oracle;

namespace DataHandlerTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string s = "你好qwerqwer";
            System.Text.Encoding encoding = System.Text.Encoding.Default;
            byte[] bytes = encoding.GetBytes(s);
            string hex = HexFormat.Bytes2Hex(bytes);
            System.Console.WriteLine(hex);

            bytes = HexFormat.Hex2Bytes(hex);
            s = encoding.GetString(bytes);
            System.Console.WriteLine(s);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            NativeOracleDataProvider odp = new NativeOracleDataProvider("adat", "adat", "adat");
            odp.Open();
            try
            {
                SelectDataSource sdt = new SelectDataSource();
                sdt.SourceDataSource = new TableDataSource("SS_DEVICE");
                sdt.Filter = new AndFilter();

                SelectCommand selectCmd = odp.CreateSelectCommand(sdt);
                selectCmd.Execute();

                SimpleUpdateCommand updateCmd = odp.CreateSimpleUpdateCommand();
                updateCmd.TableName = "SS_DEVICE";
                updateCmd.FieldValues.Add(new FieldValue("ID", "8a8080c933c4df220133c4e3fe600111", false));
                updateCmd.FieldValues.Add(new FieldValue("NAME", "asdfasdf", false));
                updateCmd.FieldValues.Add(new FieldValue("SUBSTATIONID", "8a8080c933c4df220133c4e3fe600111", true));
                updateCmd.Execute();
            }
            finally
            {
                odp.Close();
            }
        }
    }
}
